package com.plian.Tools;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class AllDayOfMonth {

    public static List<String> getDay(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(Calendar.DATE, 1);
        c.set(Calendar.HOUR_OF_DAY, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        c.set(Calendar.MILLISECOND, 0);
        int firstday = c.get(Calendar.DAY_OF_MONTH);

        Calendar lc = Calendar.getInstance();
        lc.setTime(date);
        lc.add(Calendar.MONTH, 1);
        lc.set(Calendar.DATE, 0);
        lc.set(Calendar.HOUR_OF_DAY, 23);
        lc.set(Calendar.MINUTE, 59);
        lc.set(Calendar.SECOND, 59);
        lc.set(Calendar.MILLISECOND, 999);
        int lastday = lc.get(Calendar.DAY_OF_MONTH);

        Calendar nowDate = Calendar.getInstance();
        nowDate.setTime(date);
        List list = new ArrayList();
        for (int i = 1; i < 2 + lastday - firstday; i++) {
            nowDate.set(Calendar.DAY_OF_MONTH, i);
            list.add(new java.text.SimpleDateFormat("yyyy-MM-dd").format(nowDate.getTime()));
        }
        return list;
    }
}
